package org.excilys.training.ebanking.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "COMPTE")
public class Compte {

	private int id;

	private String nomCompte;

	private double soldeCourant;

	private double encour;

	private List<Utilisateur> clients = new ArrayList<Utilisateur>();

	private List<Operation> operations = new ArrayList<Operation>();

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "nom", nullable = false)
	public String getNomCompte() {
		return nomCompte;
	}

	public void setNomCompte(String nomCompte) {
		this.nomCompte = nomCompte;
	}

	@Column(name = "solde")
	public double getSoldeCourant() {
		return soldeCourant;
	}

	public void setSoldeCourant(double soldeCourant) {
		this.soldeCourant = soldeCourant;
	}

	public double getEncour() {
		return encour;
	}

	public void setEncour(double encour) {
		this.encour = encour;
	}

	@ManyToMany
	@JoinTable(name = "UTILISATEUR_COMPTE", joinColumns = @JoinColumn(name = "id_compte"), inverseJoinColumns = @JoinColumn(name = "id_client"))
	public List<Utilisateur> getClients() {
		return clients;
	}

	public void setClients(List<Utilisateur> clients) {
		this.clients = clients;
	}

	@OneToMany(mappedBy = "compte")
	public List<Operation> getOperations() {
		return operations;
	}

	public void setOperations(List<Operation> operations) {
		this.operations = operations;
	}
}
